<!DOCTYPE html>

<html>
<head>
  <title>startView.coffee</title>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <link rel="stylesheet" media="all" href="public/stylesheets/normalize.css" />
  <link rel="stylesheet" media="all" href="docco.css" />
</head>
<body>
  <div class="container">
    <div class="page">

      <div class="header">
        
          <h1>startView.coffee</h1>
        

        
          <div class="toc">
            <h3>Table of Contents</h3>
            <ol>
              
                
                <li>
                  <a class="source" href="admin.html">
                    admin.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="api.auditData.html">
                    api.auditData.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="api.auditEvent.html">
                    api.auditEvent.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="api.html">
                    api.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="api.entity.html">
                    api.entity.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="api.map.html">
                    api.map.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="api.server.html">
                    api.server.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="api.variable.html">
                    api.variable.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="api.view.html">
                    api.view.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="app.instance.html">
                    app.instance.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="appjs.html">
                    appjs.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="data.html">
                    data.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="dataUtil.html">
                    dataUtil.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="manager.html">
                    manager.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="messages.html">
                    messages.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="auditData.html">
                    auditData.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="auditEvent.html">
                    auditEvent.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="base.html">
                    base.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="entityDefinition.html">
                    entityDefinition.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="entityObject.html">
                    entityObject.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="eventAction.html">
                    eventAction.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="eventRule.html">
                    eventRule.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="link.html">
                    link.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="map.html">
                    map.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="shape.html">
                    shape.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="user.html">
                    user.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="userSettings.html">
                    userSettings.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="variable.html">
                    variable.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="adminRoutes.html">
                    adminRoutes.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="appRoutes.html">
                    appRoutes.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="settings.html">
                    settings.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="sockets.html">
                    sockets.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="tutorial.html">
                    tutorial.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="vectors.html">
                    vectors.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="statusTabView.html">
                    statusTabView.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="toolsTabView.html">
                    toolsTabView.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="usersTabView.html">
                    usersTabView.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="adminView.html">
                    adminView.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="alertView.html">
                    alertView.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="auditDataManagerView.html">
                    auditDataManagerView.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="auditEventManagerView.html">
                    auditEventManagerView.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="baseView.html">
                    baseView.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="createMapView.html">
                    createMapView.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="entityManagerView.html">
                    entityManagerView.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="footerView.html">
                    footerView.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="helpView.html">
                    helpView.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="entitiesTabView.html">
                    entitiesTabView.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="inspectorTabView.html">
                    inspectorTabView.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="mapTabView.html">
                    mapTabView.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="shapeTabView.html">
                    shapeTabView.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="controlsView.html">
                    controlsView.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="labelEditView.html">
                    labelEditView.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="linkCreatorView.html">
                    linkCreatorView.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="linkLabelsView.html">
                    linkLabelsView.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="linkView.html">
                    linkView.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="shapeLabelsView.html">
                    shapeLabelsView.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="shapeView.html">
                    shapeView.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="shapesMoverView.html">
                    shapesMoverView.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="mapView.html">
                    mapView.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="menuView.html">
                    menuView.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="overlayView.html">
                    overlayView.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="scriptEditorView.html">
                    scriptEditorView.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="settingsView.html">
                    settingsView.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="startView.html">
                    startView.coffee
                  </a>
                </li>
              
                
                <li>
                  <a class="source" href="variableManagerView.html">
                    variableManagerView.coffee
                  </a>
                </li>
              
            </ol>
          </div>
        
      </div>

      
        
        <h2 id="start-view">START VIEW</h2>

        
      
        
        <p>Represents the Start overlay which is shown automatically when the user
opens the app for the first time.</p>

        
          <div class='highlight'><pre><span class="class"><span class="keyword">class</span> <span class="title">SystemApp</span>.<span class="title">StartView</span> <span class="keyword">extends</span> <span class="title">SystemApp</span>.<span class="title">OverlayView</span></span>

    <span class="attribute">$mapList</span>: <span class="literal">null</span>          <span class="comment"># the UL containing all available maps</span>
    <span class="attribute">$imgPreview</span>: <span class="literal">null</span>       <span class="comment"># the map image preview</span></pre></div>
        
      
        
        <h2 id="init-and-dispose">INIT AND DISPOSE</h2>

        
      
        
        <p>Init the Start overlay view.</p>

        
          <div class='highlight'><pre>    <span class="attribute">initialize</span>:<span class="function"> =&gt;</span>
        <span class="property">@overlayInit</span> <span class="string">"#start"</span>
        <span class="property">@setDom</span>()
        <span class="property">@setEvents</span>()
        <span class="property">@bindMaps</span>()</pre></div>
        
      
        
        <p>Dispose the Start overlay view.</p>

        
          <div class='highlight'><pre>    <span class="attribute">dispose</span>:<span class="function"> =&gt;</span>
        <span class="property">@baseDispose</span>()</pre></div>
        
      
        
        <p>Set the DOM elements cache.</p>

        
          <div class='highlight'><pre>    <span class="attribute">setDom</span>:<span class="function"> =&gt;</span>
        <span class="property">@$menuItem</span> = $ <span class="string">"#menu-maps"</span>
        <span class="property">@$mapList</span> = $ <span class="string">"#start-maps"</span>
        <span class="property">@$imgPreview</span> = $ <span class="string">"#start-map-preview"</span></pre></div>
        
      
        
        <p>Bind events to the DOM.</p>

        
          <div class='highlight'><pre>    <span class="attribute">setEvents</span>:<span class="function"> =&gt;</span>
        contents = <span class="property">@$el</span>.children <span class="string">".full-overlay-contents"</span>
        contents.mousemove <span class="property">@wrapperMouseMove</span></pre></div>
        
      
        
        <p>Bind the map list.</p>

        
          <div class='highlight'><pre>    <span class="attribute">bindMaps</span>:<span class="function"> =&gt;</span>
        <span class="keyword">if</span> SystemApp.Data.maps.fetching <span class="keyword">or</span> SystemApp.Data.maps.models.length &lt; <span class="number">1</span>
            _.delay <span class="property">@bindMaps</span>, SystemApp.Settings.general.refetchDelay
            <span class="keyword">return</span>

        <span class="keyword">if</span> SystemApp.Settings.map.enableLocalMap
            map = <span class="keyword">new</span> SystemApp.Map()
            map.initLocalMap()
            <span class="property">@addMapToList</span> map

        <span class="property">@addMapToList</span> item <span class="keyword">for</span> item <span class="keyword">in</span> SystemApp.Data.maps.models</pre></div>
        
      
        
        <p>Add a single <a href="map.html">Map</a> to the <code>$mapList</code> element.</p>

        
          <div class='highlight'><pre>    <span class="attribute">addMapToList</span>: <span class="function"><span class="params">(map)</span> =&gt;</span>
        name = $(document.createElement <span class="string">"div"</span>)
        name.addClass <span class="string">"name"</span>
        name.html map.name()
        name.click map.urlKey(), <span class="property">@mapClick</span>

        info = $(document.createElement <span class="string">"div"</span>)
        info.addClass <span class="string">"info"</span>
        info.html SystemApp.Messages.mapInfoStats.replace(<span class="string">"#S"</span>, map.shapes().length).replace(<span class="string">"#L"</span>, map.links().length)

        div = $(document.createElement <span class="string">"div"</span>)
        div.mouseenter map.id, <span class="property">@showMapPreview</span>
        div.append(name).append(info)

        <span class="property">@$mapList</span>.append div</pre></div>
        
      
        
        <p>When mouse moves around any part of the view BUT the individual map divs, hide the preview image.</p>

        
          <div class='highlight'><pre>    <span class="attribute">wrapperMouseMove</span>: <span class="function"><span class="params">(e)</span> =&gt;</span>
        src = $ e.target
        testCurrent = src.attr(<span class="string">"id"</span>) <span class="keyword">isnt</span> <span class="string">"start-map-preview"</span>
        testParent = src.parent().attr(<span class="string">"id"</span>) <span class="keyword">isnt</span> <span class="string">"start-maps"</span> <span class="keyword">and</span> src.parent().parent().attr(<span class="string">"id"</span>) <span class="keyword">isnt</span> <span class="string">"start-maps"</span>
        <span class="keyword">if</span> testCurrent <span class="keyword">and</span> testParent
            <span class="property">@$imgPreview</span>.css <span class="string">"display"</span>, <span class="string">"none"</span></pre></div>
        
      
        
        <p>When user clicks on a map name, open the map by changing the current URL.</p>

        
          <div class='highlight'><pre>    <span class="attribute">mapClick</span>: <span class="function"><span class="params">(e)</span> =&gt;</span>
        SystemApp.routes.navigate <span class="string">"#map/"</span> + e.data, {<span class="attribute">trigger</span>: <span class="literal">true</span>}</pre></div>
        
      
        
        <p>Update the right image to show a preview of the current map under the mouse pointer.</p>

        
          <div class='highlight'><pre>    <span class="attribute">showMapPreview</span>: <span class="function"><span class="params">(e)</span> =&gt;</span>
        <span class="property">@$imgPreview</span>.attr <span class="string">"src"</span>, SystemApp.Settings.map.thumbnailBaseUrl + e.data + <span class="string">".png"</span>
        <span class="property">@$imgPreview</span>.css <span class="string">"display"</span>, <span class="string">""</span>
        e.preventDefault()
        e.stopPropagation()</pre></div>
        
      
      <div class="fleur">h</div>
    </div>
  </div>
</body>
</html>
